package com.isccp.efi.service.impl;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.isccp.efi.dto.B013;
import com.isccp.efi.dto.TDpcaEfi074;
import com.isccp.efi.dto.TDpcaEfi075;
import com.isccp.efi.mapper.TDpcaEfi075Mapper;
import com.isccp.efi.service.TDpcaEfi074Service;
import com.isccp.efi.mapper.TDpcaEfi074Mapper;
import com.isccp.efi.service.TDpcaEfi075Service;
import com.isccp.efi.util.GetWsDataUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author songyong
* @description 针对表【t_dpca_efi074】的数据库操作Service实现
* @createDate 2024-02-04 17:01:31
*/
@Service
public class TDpcaEfi074ServiceImpl extends ServiceImpl<TDpcaEfi074Mapper, TDpcaEfi074>
    implements TDpcaEfi074Service{
    private static final Logger log = LoggerFactory.getLogger(TDpcaEfi074ServiceImpl.class);

@Resource
private TDpcaEfi075Mapper tDpcaEfi075Mapper;

    @Resource
    private GetWsDataUtil getWsDataUtil;
    @Override
    public void syncData() {


        QueryWrapper queryWrapper = new QueryWrapper<TDpcaEfi074>().eq("TRANSFLAG", 2);


        List<TDpcaEfi074> efi074List=  this.getBaseMapper().getSendList();

        for(TDpcaEfi074 efi074:efi074List){

            try {
                JSONObject data=new JSONObject();
                data.put("main",efi074);

                List<TDpcaEfi075> efi075List=  tDpcaEfi075Mapper.getSendList(efi074);
                data.put("list",efi075List);
                JSONObject res= getWsDataUtil.sendBL(data);

                if("00".equals(res.getString("code"))){

                    TDpcaEfi074 update =new TDpcaEfi074();
                    update.setTRANSFLAG(1);
                    update.setROWID(efi074.getROWID());
                    this.getBaseMapper().updateById(update);
                }
            } catch (Exception e) {
                log.error("发送发货通知失败",e);
            }

        }

    }
}




